﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DoAnASP;
public partial class uscThongTinCN : System.Web.UI.UserControl
{
    
    DataTable dt = new DataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if ( (bool)Session["DangDangNhap"] == true )
       {

          
            lbltenQuyen.Text = LayTenQuyen();
            lbDangNhap.Text = Session["HoTen"].ToString();
            Session["MaQuyen"] = dt.Rows[0]["MaQuyen"];
            if (int.Parse(Session["MaQuyen"].ToString()) == 1)
            {
                hplQuanTri.Visible = false;
            }
            else
            {
                hplQuanTri.Visible = true;
            }
       }

    }
    protected void btDangXuat_Click(object sender, EventArgs e)
    {
        Session["KiemTra"] = null;
        Session["DangDangNhap"] = false;
        Session["ThanhVien"] = "";
        Session["HoTen"] = "";
        Response.Redirect(Request.RawUrl);
        //Response.Redirect("TrangChu.aspx");
    } 

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("DoiMatKhau.aspx");
    }

   
   // TenQuyen = dt.Rows[0]["Ten"].ToString();
   // TenNhanVien = dt.Rows[0]["HoTen"].ToString();

    string LayTenQuyen()
    {
        string TenQuyen;
        DTO_NhanVien nv = new DTO_NhanVien();
        BUS_NhanVien nv1 = new BUS_NhanVien();
        DAO_NhanVien d = new DAO_NhanVien();
        nv.Username = Session["ThanhVien"].ToString();
        dt= nv1.LayTenQuyen(nv);
        TenQuyen = dt.Rows[0]["Ten"].ToString();
        Session["HoTen"] = dt.Rows[0]["HoTen"].ToString();
        return TenQuyen;
    }
}